package com.xpgk.mvc.leaveApplication;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Record;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.bentryRegister.Customer;
import com.xpgk.mvc.detailAnnounce.DetailAnnounce;
import com.xpgk.mvc.organization.Organization;

public class LeaveApplicationController  extends BaseController{
	private LeaveApplicationService leaveApplicationService;
	public void index(){
		Organization organ=Organization.dao.findById(getCUserOrganIds());
		setAttr("organization",organ);
		render("leaveApplication.html");
	}
	//保存请假顾客
	public void saveLeave(){
		//获取当前登录机构id
		String organid=getCUserOrganIds();
		//获取请假顾客id
		String customerIds=getPara("customer.ids");
		//获取请假顾客姓名
		String name=getPara("customer.name");
		//获取请假顾客手机号
		String phone=getPara("customer.phone");
		//获取请假顾客编号
		String hybh=getPara("customer.hybh");
		//获取创建人id
		String createId=getCUserIds();
		//获取创建人姓名
		String creater=getCUser().get("username");
		//获取创建日期
		Date createDate=new Date();
		LeaveApplication leaveApplication=getModel(LeaveApplication.class,"leaveApplication");
		RenderBean result=leaveApplicationService.saveLeave(leaveApplication,organid,customerIds,name,phone,hybh,createId,creater,createDate);
		renderJson(result.getMap());
	}
	//体重登记 请假
	public void getCustomerLeave(){
		String customerIds=getPara("customerIds");
		Customer customer=new Customer();
		customer=customer.findById(customerIds);
		System.out.println(customer);
		setAttr("customer",customer);
		render("leaveApplication2.html");
	}

	public void  getLeave(){
		String json = paging(splitPage, LeaveApplication.sqlId_splitPageSelect,LeaveApplication.sqlId_splitPageFrom);
		renderJson(json);
	}
	
}
